﻿using MaterialDesignThemes.Wpf;
using System.IO;
using System.Reflection;
using System.Windows;

namespace LS.Screening.UI.Common.Controls
{
    public class CommonApplication : Application
    {
        public string StartupPage { get; set; }
        public FlowDirection InitialFlowDirection { get; set; }
        public BaseTheme InitialTheme { get; set; }

        public virtual void RegisterServices()
        {
            var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "LS.Screening.UI*.dll").ToList();
            var assemblies = files.Select(f => Assembly.LoadFrom(f.Trim())).ToArray();
            ServiceHelper.RegisterServices(assemblies);
            ServiceHelper.BuildServices();
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            RegisterServices();
        }
    }
}
